<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}

</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layuimini-main">

        <form class="layui-form" action="">
            <input type="hidden" name="id" value="{$id}">
            <div class="layui-form-item">
                <label class="layui-form-label">账号昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" value="{$info.nickname}" lay-verify="nickname" autocomplete="off" placeholder="请输入账号昵称" class="layui-input iwidth" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input type="text" name="account" value="{$info.account}" lay-verify="account" autocomplete="off" placeholder="请输入账号" class="layui-input iwidth" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">原密码</label>
                <div class="layui-input-block">
                    <input type="password" name="rawpass" lay-verify="rawpassword" autocomplete="off" placeholder="请输入原密码" class="layui-input iwidth" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="password" autocomplete="off" placeholder="请输入账号密码6到12位" class="layui-input iwidth" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="confirm_pass" placeholder="请输入确认密码" autocomplete="off" class="layui-input iwidth">
                </div>
                <!--<div class="layui-form-mid layui-word-aux">请务必填写用户名</div>-->
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
                </div>
            </div>
        </form>

    </div>
</div>

{include file="public/footer" /}

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , $ = layui.$;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            nickname: function (value) {
                if (value == '') {
                    return '账号昵称不能为空';
                }
            },
            account: function (value) {
                if (value == '') {
                    return '账号不能为空';
                }
            }
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(add)', function (data) {
            $.ajax({
                url: '/admin/systemset/write?active=ajax',
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (res) {
                    if (res.status == true) {    // 获得frame索引
                        parent.layer.msg(res.msg, {icon:1,time: 1000}, function () {
                            //重新加载父页面
                            parent.location.reload();
                        });
                        return;
                    } else{
                        layer.msg(res.msg, {icon:5,time: 1000}, function () {
                        });
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });
            return false;
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })*/
        });

        //表单初始赋值
        form.val('example', {
            "username": "贤心" // "name": "value"
            , "password": "123456"
            , "interest": 1
            , "like[write]": true //复选框选中状态
            , "close": true //开关状态
            , "sex": "女"
            , "desc": "我爱 layui"
        })


    });
</script>
<!--图片上传-->
</body>
</html>